!
    function(a) {
        "use strict";
        var b = function(a) {
            this.opts = {},
                this.dom = {},
                this.api = {},
                this.maxDomainLen = 30,
                this.jsonPrice = {},
                this.jsonProduct = {},
            a && (this.conf(a), this.init()),
            window.localStorage.getItem("transfer_data") && (this.dom.iptMulti.val(window.localStorage.getItem("transfer_data")).change(), window.localStorage.removeItem("transfer_data"))
        };
        b.prototype = {
            init: function() {
                var b = this;
                return b.dom.inputCheckboxDnsProduct.prop("checked", !1),
                    b.dom.inputCheckboxAgree.prop("checked", !1),
                    b.dom.inputCheckboxAgree.closest("p").hide(),
                    b.dom.inputCheckboxDnsProduct.attr("val", "0"),
                    a("#dnshidden").val(""),
                    a("#dnsPeriod").val(""),
                    a("#dnsPricingCycle").val(""),
                    b._placeholder()._checkNumStatus()._eventDrive(),
                    c.disable(this.dom.btnSubmitCheck),
                    b.checkLogin(),
                    b._getPriceData(function(c) {
                        var d = c.model;
                        for (var e in d) {
                            var f = d[e];
                            a('.J_price[pid="' + f.productID + '"]').html(f.money + "元"),
                                b.jsonPrice[f.productID] = f.money
                        }
                    }),
                    this
            },
            conf: function(a) {
                this.opts = a,
                a.dom && (this.dom = jQuery.extend({},
                    this.dom, a.dom)),
                a.api && (this.api = jQuery.extend({},
                    this.api, a.api));
                for (var b = 0,
                         c = this.opts.productID,
                         d = c.length; d > b; b++) this.jsonProduct[c[b][0]] = c[b][1];
                var e = a.dom.countTip,
                    f = parseInt(e.attr("max"));
                return ! isNaN(f) && f > 0 && (this.maxDomainLen = f),
                    this
            },
            checkLogin: function(a, b) {
                return a = a ||
                    function() {},
                    b = b ||
                        function() {},
                    window.__checkLoginResult ? a(window.__checkLoginResult) : void HiChina.ajax.ajaxJsonp(this.api.checkLogin, {},
                        function(c) {
                            var d = c.msg;
                            "OK" == d && "200" == c.code ? (window.__checkLoginResult = c, a(c)) : (window.__checkLoginResult = !1, b(c))
                        })
            },
            submitCheck: function() {
                var b = this;
                if (this._checkNumStatus(), a(".J_countTip").hasClass("ui-err")) return ! 1;
                c.disable(this.dom.btnSubmitCheck);
                var e = this.dom.iptMulti,
                    f = e.val(),
                    g = c.multiTxtToArr(f),
                    h = (g.length, []);
                for (var i in g) {
                    var j = g[i],
                        k = c.splitBySpace(j),
                        l = k.length;
                    l > 1 ? h.push({
                        domain: encodeURIComponent(k[0].toLowerCase()),
                        password: encodeURIComponent(k[1])
                    }) : h.push({
                        domain: encodeURIComponent(k[0]),
                        password: encodeURIComponent("")
                    })
                }
                if (h.length) {
                    var m = b.dom.boxTransResult,
                        n = m.find(".J_loading");
                    n.length || m.prepend(d.loading),
                        m.show(),
                        a("html,body").animate({
                            scrollTop: m.offset().top
                        }),
                        c.getJsonP(this.api.batchCheck, h,
                            function(a) {
                                b._renderTransResult(a)
                            },
                            function(a, b) {})
                } else alert("请输入域名和对应密码"),
                    e.focus();
                return this
            },
            _checkNumStatus: function() {
                var a = this.dom.iptMulti,
                    b = this.dom.countTip,
                    d = this.dom.btnSubmitCheck,
                    e = c.multiTxtToArr(a.val()).length,
                    f = this.dom.boxAvailable.find(".J_list").children("li").length,
                    g = this.maxDomainLen - f - e;
                return e ? c.enable(d) : c.disable(d),
                    0 > g ? (b.text("已经超出" + -1 * g + "个域名").addClass("ui-err"), c.disable(d)) : b.text("还可输入" + g + "个域名").removeClass("ui-err"),
                    this
            },
            _renderTransResult: function(b) {
                var c = this,
                    e = this.dom.boxTransResult,
                    f = this.dom.boxNotAvailable,
                    g = this.dom.boxAvailable,
                    h = this.dom.boxSummury,
                    i = this.dom.boxRsBtm,
                    j = f.find(".J_list"),
                    k = f.find(".J_head"),
                    l = g.find(".J_list"),
                    m = g.find(".J_head");
                if ("OK" == b.msg) {
                    var n = b.model,
                        o = (n.length, l.children("li").length),
                        p = j.children("li").length;
                    for (var q in n) {
                        var r = n[q];
                        "1001" == r.errorCode ? r.message = "该域名未被注册，不能转入": "1002" == r.errorCode ? r.message = "域名为禁止转移状态，不能转入。您可联系原域名注册商更改域名状态": "1003" == r.errorCode ? r.message = "域名注册60天内，不能转入": "1004" == r.errorCode ? r.message = "该域名已经在万网管理": "1005" == r.errorCode ? r.message = "该域名距离到期日不足15天，不能转入": "1006" == r.errorCode ? r.message = "域名已提交转入。如尚未付款，登录会员中心>未付款订单完成": "1007" == r.errorCode ? r.message = "查询超时，请重新查询": "1008" == r.errorCode ? r.message = "域名格式错误或该后缀暂不支持转入，请重新输入": "1009" == r.errorCode ? r.message = "域名转移密码未填写": "1016" == r.errorCode ? r.message = "该域名在其他账户设置过域名解析，如果继续会导致该账户解析记录被清除": "1017" == r.errorCode ? r.message = "该域名为锁定（hold）状态，不能转入，您可联系原注册商更改域名状态": r.canTransfer ? r.message = "": r.message = r.message || "域名不存在，请重新输入",
                            r.canTransfer ? l.find('li[domain="' + r.domain + '"]').length || (l.append(d.availableItem(r.domain, r.password, r.productId, r.message)), o++) : (j.append(d.notAvailableItem(r.domain, r.message, r.errorCode)), p++)
                    }
                    if (k.html(d.notAvailableHd(p)), m.html(d.availableHd(o)), p && f.show(), o) {
                        var s = !1;
                        a.each(l.children("li"),
                            function(b, c) {
                                return /(\.ltd|\.shop)$/gi.test(a.trim(a(c).attr("domain"))) ? (s = !0, !1) : void 0
                            }),
                            o >= 5 || 1 == s ? (c.dom.inputCheckboxDnsProduct.prop("checked", !1), c.dom.inputCheckboxAgree.prop("checked", !1), c.dom.inputCheckboxDnsProduct.attr("val", "0"), c.dom.inputCheckboxDnsProduct.closest(".summurydns").hide(), c.dom.inputCheckboxAgree.closest("p").hide(), a("#dnshidden").val(""), a("#dnsPeriod").val(""), a("#dnsPricingCycle").val("")) : c.dom.inputCheckboxDnsProduct.closest(".summurydns").show(),
                            c._renderSummury(),
                            c.renderAgreements(),
                            h.show(),
                            g.show(),
                            h.show(),
                            i.show()
                    }
                } else alert(b.tips);
                e.find(".J_loading").remove(),
                    this.dom.iptMulti.val("").change(),
                    a("html,body").animate({
                        scrollTop: e.offset().top
                    })
            },
            renderAgreements: function() {
                for (var b = this,
                         c = b.dom.boxTransResult,
                         d = c.find(".J_agreementList"), e = b.dom.boxAvailable.find(".J_list").children("li"), f = '<input name="agreement" type="checkbox" value="{domainSuff}" id="{domainSuff}"> <label for="{domainSuff}">我已阅读，理解并接受[<a href="//wanwang.aliyun.com/agreement/product/index.html?productID={pid}" target="_blank">{domainSuff}域名转入在线服务条款</a>]</label>', g = [], h = {},
                         i = 0, j = e.length; j > i; i++) {
                    var k = a(e[i]),
                        l = k.attr("domain"),
                        m = l.indexOf("."),
                        n = l.substring(m),
                        o = l.substring(m + 1);
                    h[o] || (h[o] = 1, g.push(f.replaceAll("{domainSuff}", n).replace("{pid}", k.attr("pid"))))
                }
                d.html(g.join(""))
            },
            submitOrder: function(b) {
                var d = this,
                    e = this.dom.boxAvailable.find(".J_list").children("li"),
                    f = d.dom.boxTransResult,
                    g = f.find(".J_agreementList"),
                    h = g.find('input[name="agreement"]').not(":checked");
                if (h.length > 0) return HiChina.popup.alert({
                    contTitle: "请阅读并接受" + h[0].value + "协议再继续转移"
                }),
                    b.preventDefault(),
                    !1;
                if (!a("#agreementICANN").prop("checked")) return HiChina.popup.alert({
                    contTitle: "请选择，关闭“域名信息修改成功后60天内禁止转出阿里云”"
                }),
                    b.preventDefault(),
                    !1;
                if (!a("#readCheck").prop("checked")) return HiChina.popup.alert({
                    contTitle: "请阅读并接受《域名信息修改服务条款》"
                }),
                    b.preventDefault(),
                    !1;
                if (Number(d.dom.inputCheckboxDnsProduct.attr("val")) > 0) {
                    if (!d.dom.inputCheckboxAgree.prop("checked")) return HiChina.popup.alert({
                        contTitle: "请阅读并接受云解析(企业版)服务条款协议再继续转移"
                    }),
                        b.preventDefault(),
                        this;
                    a("#dnshidden").val("1"),
                        a("#dnsPeriod").val(d.dom.inputCheckboxDnsProduct.attr("periodvalue")),
                        a("#dnsPricingCycle").val(d.dom.inputCheckboxDnsProduct.attr("periodtype"))
                } else a("#dnshidden").val(""),
                    a("#dnsPeriod").val(""),
                    a("#dnsPricingCycle").val("");
                var i = jQuery(".template-id:checked").val();
                if (!i) return HiChina.popup.alert({
                    contTitle: "请选择一个已实名认证的域名信息模板。"
                }),
                    b.preventDefault(),
                    !1;
                d.dom.btnSubmitOrder.parent().find("input[name=tid]").val(i),
                    c.disable(d.dom.btnSubmitOrder);
                var j = [];
                e.each(function(b, c) {
                    j.push({
                        domain: a(c).attr("domain"),
                        password: a(c).attr("pwd"),
                        productID: a(c).attr("pid")
                    })
                }),
                    d.dom.btnSubmitOrder.parent().find("input[name=data]").val(jQuery.toJSON(j));
                var k = d.dom.inputPromotionCode.val().trim() || "";
                return d.dom.btnSubmitOrder.parent().find("input[name=customcoupon]").val(k),
                    a("#from_confirmOrder").submit(),
                    this
            },
            _eventDrive: function() {
                var b = this,
                    c = this.dom.boxAvailable,
                    e = c.find(".J_list"),
                    f = c.find(".J_head"),
                    g = this.dom.inputPromotionCode;
                return this.dom.btnSubmitCheck.click(function() {
                    b.checkLogin(function() {
                            b.submitCheck()
                        },
                        function() {
                            window.localStorage.setItem("transfer_data", b.dom.iptMulti.val()),
                                window.location.href = b.api.urlLogin + "?returnurl=" + encodeURIComponent(window.location.href)
                        })
                }),
                    this.dom.btnPromotionCode.click(function() {
                        var c, d = g.val();
                        0 != d.trim().length && (c = a(".J_promotionInfo"), c.find(".success").text(""), c.find(".error").text(""), jQuery.ajax({
                            url: b.api.checkPromotion,
                            type: "GET",
                            dataType: "jsonp",
                            contentType: "application/json",
                            jsonp: "callback",
                            data: {
                                customCoupon: d
                            },
                            success: function(a) {
                                "OK" == a.msg ? c.find(".success").text(a.model) : c.find(".error").text(a.tips)
                            },
                            error: function(a, b, d) {
                                c.find(".error").text("请求失败，请重试")
                            }
                        }))
                    }),
                    this.dom.btnSubmitOrder.click(function(a) {
                        b.submitOrder(a)
                    }),
                    this.dom.iptMulti.change(function() {
                        b._checkNumStatus()
                    }).keyup(function() {
                        b._checkNumStatus()
                    }),
                    this.dom.btnAddMore.click(function() {
                        var c = b.dom.boxTransfer.offset().top;
                        a("html,body").animate({
                                scrollTop: c
                            },
                            function() {
                                b.dom.iptMulti.focus()
                            })
                    }),
                    this.dom.inputCheckboxDnsProduct.on("click",
                        function() {
                            0 == Number(a(this).attr("val")) ? (b.dom.inputCheckboxDnsProduct.prop("checked", !0), b.dom.inputCheckboxAgree.prop("checked", !0), b.dom.inputCheckboxAgree.closest("p").show(), a(this).attr("val", "1")) : (b.dom.inputCheckboxDnsProduct.prop("checked", !1), b.dom.inputCheckboxAgree.prop("checked", !1), b.dom.inputCheckboxAgree.closest("p").hide(), a(this).attr("val", "0"))
                        }),
                    this.dom.inputCheckboxAgree.on("click",
                        function() {}),
                    this.dom.boxAvailable.delegate(".J_list .J_btnRemove", "click",
                        function() {
                            var c = a(this).parents("li");
                            c.attr("pid"),
                                c.attr("domain");
                            c.remove();
                            var g = e.children("li").length;
                            f.html(d.availableHd(g));
                            var h = !1;
                            a.each(e.children("li"),
                                function(b, c) {
                                    return /(\.ltd|\.shop)$/gi.test(a.trim(a(c).attr("domain"))) ? (h = !0, !1) : void 0
                                }),
                                g >= 5 || 1 == h ? (b.dom.inputCheckboxDnsProduct.prop("checked", !1), b.dom.inputCheckboxAgree.prop("checked", !1), b.dom.inputCheckboxDnsProduct.attr("val", "0"), b.dom.inputCheckboxDnsProduct.closest(".summurydns").hide(), b.dom.inputCheckboxAgree.closest("p").hide(), a("#dnshidden").val(""), a("#dnsPeriod").val(""), a("#dnsPricingCycle").val("")) : b.dom.inputCheckboxDnsProduct.closest(".summurydns").show(),
                                b._renderSummury()
                        }),
                    this
            },
            _placeholder: function() {
                return c.placeholder(this.dom.iptMulti, this.dom.tipMulti),
                    this
            },
            _getPriceData: function(a, b) {
                a = a ||
                    function() {},
                    b = b ||
                        function() {};
                var c = this.opts.productID,
                    d = [];
                for (var e in c) d.push({
                    productID: c[e][0],
                    action: "transfer",
                    amount: 1,
                    period: 12
                });
                HiChina.ajax.getProductInfoStatic(d,
                    function(b) {
                        a(b)
                    },
                    function(a, c) {
                        b(a, c)
                    })
            },
            _getProductGroup: function() {
                var b = this,
                    c = this.dom.boxAvailable,
                    d = c.find(".J_list").children("li"),
                    e = {};
                return d.each(function(c, d) {
                    var f = a(d).attr("pid"),
                        g = a(d).attr("domain"),
                        h = b.jsonProduct[f],
                        i = b.jsonPrice[f];
                    void 0 == e[f] ? e[f] = [g, h, i, 1] : e[f][3]++
                }),
                    e
            },
            _renderSummury: function() {
                var b = this.dom.boxSummury,
                    c = this._getProductGroup(),
                    e = 0,
                    f = d.domainGroup(c);
                b.find(".J_con").html(f);
                for (var g in c) e += c[g][2] * c[g][3];
                return a(".J_rsBtm .money").text(e),
                    this
            }
        };
        var c = {
                multiTxtToArr: function(a) {
                    a = jQuery.trim(a);
                    var b = [];
                    if (a) {
                        var c = a.split(/\n/);
                        for (var d in c) jQuery.trim(c[d]) && b.push(c[d])
                    }
                    return b
                },
                splitBySpace: function(a) {
                    return jQuery.trim(a).split(/[\t\s]+/)
                },
                disable: function(a) {
                    a.attr("disabled", "disabled")
                },
                enable: function(a) {
                    a.removeAttr("disabled")
                },
                placeholder: function(a, b) {
                    var c = function() {
                        var c = a.val();
                        "" == c ? b.show() : b.hide()
                    };
                    a.change(function() {
                        c()
                    }).keyup(function() {
                        c()
                    })
                },
                post: function(a, b, c, d) {
                    c = c ||
                        function() {},
                        d = d ||
                            function() {},
                        jQuery.ajax({
                            url: a,
                            type: "POST",
                            dataType: "json",
                            contentType: "application/json",
                            data: jQuery.toJSON(b),
                            success: function(a) {
                                c(a)
                            },
                            error: function(a, b, c) {
                                throw d(a, b, c),
                                    c
                            }
                        })
                },
                getJsonP: function(a, b, c, d) {
                    c = c ||
                        function() {},
                        d = d ||
                            function() {};
                    var e = {},
                        f = encodeURIComponent(jQuery.toJSON(b)).length,
                        g = b.length;
                    f > 1900 && (g = "Microsoft Internet Explorer" == navigator.appName ? 8 : 15);
                    var h = function() {
                        if (!b.length) return void c(e);
                        var f = b.splice(0, g);
                        jQuery.ajax({
                            url: a,
                            type: "GET",
                            dataType: "jsonp",
                            contentType: "application/json",
                            jsonp: "jsoncallback",
                            data: {
                                inputJson: jQuery.toJSON(f)
                            },
                            success: function(a) {
                                e.model && e.model.length ? e.model = e.model.concat(a.model) : e = a,
                                    h()
                            },
                            error: function(a, b, c) {
                                throw d(a, b, c),
                                    c
                            }
                        })
                    };
                    h()
                }
            },
            d = window.transferTmpl || {};
        window.Transfer = b
    } (jQuery);